<?php
/**
 * Created by PhpStorm.
 * User: wodrow
 * Date: 9/4/17
 * Time: 3:58 PM
 */

namespace common\components\tools;


class Out
{
    public static function bo_array($arr, &$out = [], $k_attr = [], &$deep = 0)
    {
        if (is_array($arr)){
            $deep++;
            foreach($arr as $k => $v){
                $attr = null;
                foreach ($k_attr as $k1 => $v1){
                    if ($k1 == $k){
                        $attr = $v1;
                    }
                }
                $out[] = [
                    'k' => $k,
                    'v' => is_array($v)?null:$v,
                    'attr' => $attr,
                    'deep' => $deep,
                ];
                self::bo_array($v, $out, $k_attr, $deep);
            }
            $deep--;
        }
    }
}